<?

class sign_activate_action extends action_controller
{
	public function execute()
	{
		$data = explode(';', base64_decode($_GET['d']));
		if ( !$id = $data[0] ) response::redirect('/');

		$user = user_peer::get($id);
		if ( $user['active'] ) response::redirect('/');

		$sign = $data[1];

		if ( $sign != md5($id . $user['email'] . $user['password'] . 'activation') )
			response::redirect('/');

		user_peer::save($id, array('active' => 1));
		session::authorize($id);
	}
}